﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Game
{
    public class FunctionList
    {
        public Image AddImages(Canvas canvas, string address, double left, double top)
        {
            Uri uri = new Uri(address, UriKind.Relative);
            BitmapImage imgSource = new BitmapImage(uri);
            Image img = new Image() { Source = imgSource };
            canvas.Children.Add(img);
            Canvas.SetLeft(img, left);
            Canvas.SetTop(img, top);
            return img;
        }

        public void MoveImages(Canvas canvas, Image img, double toLeft, double toTop, int distance)
        {
            
            if ((double)img.GetValue(Canvas.LeftProperty) < toLeft)
                img.SetValue(Canvas.LeftProperty,(double)img.GetValue(Canvas.LeftProperty) + distance);
            else if (Canvas.GetLeft(img) > toLeft)
                Canvas.SetLeft(img, Canvas.GetLeft(img) - distance);
            else if (Canvas.GetTop(img) > toTop)
                Canvas.SetTop(img, Canvas.GetTop(img) + distance);
            else if (Canvas.GetTop(img) > toTop)
                Canvas.SetTop(img, Canvas.GetTop(img) - distance);
        }
    }
}
